<?php
class Sys_corner_case_model extends CI_Model {

	public function __construct(){
		parent::__construct();
		$this->db = $this->load->database('default',true);
	}

	public function  query_corner_cases() {
		$sql ="select * from sys_corner_case where  be_delete ='0' and  parent_id ='$parent_id' order by corner_case_id asc";
		$query	=$this->db->query($sql);
		if ($query->num_rows()>0) {
			return $query->result_array();
		}
	}

	public function query_corner_case_info($corner_case_id){
		$sql ="select * from  sys_corner_case where  be_delete ='0' and  corner_case_id ='$corner_case_id' limit 1";
		$query	=$this->db->query($sql);
		if ($query->num_rows()>0) {
			return $query->row_array();
		}
	}

	public function query_corner_case_info_by_name($corner_case_name){
		$sql ="select * from  sys_corner_case where be_delete ='0' and  corner_case_name ='$corner_case_name' limit 1";
		$query	=$this->db->query($sql);
		if ($query->num_rows()>0) {
			return $query->row_array();
		}
	}
	public function insert_corner_case($corner_case){
		$corner_case['be_delete']=0;
		$this->db->insert('sys_corner_case',$corner_case);
	}
	public function update_corner_case($corner_case,$corner_case_id){
		$this->db->where('corner_case_id',$corner_case_id);
		$this->db->update('sys_corner_case',$corner_case);
	}

	public function set_delete_corner_case($corner_case_id){
		$sql ="update sys_corner_case set be_delete ='1' where corner_case_id='$corner_case_id'";
		$this->db->query($sql);
	}

	public function query_corner_case_list($start,$limit) {
		$sql ="select corner_case_id,corner_case_name from sys_corner_case where be_delete ='0'  order by corner_case_id asc limit $start,$limit";
		$query =$this->db->query($sql);
		if ($query) {
			return $query->result_array();
		}
	}

	public function query_corner_case_num(){
		$sql ="select count(corner_case_id) as num from sys_corner_case  where be_delete ='0' ";
		$query =$this->db->query($sql);
		if ($query){
			$row =$query->row_array();
			return $row['num'];
		}
	}
	public function get_all_corner_case() {
		$sql ="select corner_case_id,corner_case_name from sys_corner_case where be_delete ='0'  order by corner_case_id asc";
		$query =$this->db->query($sql);
		if ($query) {
			return $query->result_array();
		}
	}
}
?>